﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Agents.Agent
{
    public partial class AgentMenu : System.Web.UI.Page
    {
        #region Event Handlers

        /// <summary>
        /// Occurs when the page loads and shows details about the agent
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Queries queries = new Queries();

            // Do not do on logout
            if ((!IsPostBack) && (!String.IsNullOrEmpty(Page.User.Identity.Name)))
            {
                Agents agent = queries.GetAgentByUserName(Page.User.Identity.Name);

                // If the agent is with a client, redirect him to "with client" page
                if ((agent.Status != "במשמרת") && (agent.Status != "לא במשמרת"))
                {
                    Clients client = queries.GetClient(agent.Status);
                    Response.Redirect("StartShiftDisplay.aspx?clientId=" + client.Id);
                }

                lblStatus.Text = agent.Status;
            }
        }

        #endregion
    }
}